<template>
  <!-- 通知通告查看页面 -->
  <div>
    <!-- 搜索 -->
    <TopFilter
      :list="topFilterInit"
      :cols="3"
      labelWidth="90"
      @filterChange="changeHandle"
      @onCollapse="collapseHandle"
    ></TopFilter>

    <!-- table -->
    <FilterTable
      ref="table"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :isSelectColumn="false"
      :onColumnsChange="columns => this.columns = columns"
     columnsRef="todoTask_mtodo_index_01"

    >
    </FilterTable>

    <!-- 详情窗口 -->
    <Drawer
      :visible.sync="visibleDrawer"
      title="通知通告查看"
      :width="920"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
       >
      <info-modal v-model="initData" @close="infoClose" />
    </Drawer>

  </div>
</template>

<script>
import { getList,getTodoList } from '@/api/cms-api/todoTask/view/index';
import { dictionary } from '@/utils/dictMixin';
import infoModal from './info';
import { formatdateByDay } from '@/utils';

export default {
   mixins: [dictionary],
   components: {
    infoModal
   },
   data(){
     return {
       topFilterInit: this.topFilterInitFun(),
       columns: this.creatHeader(),
       fetchApi:getTodoList,
       fetchParams: {},
       visibleDrawer:false,
       initData:{}
     }
   },
   methods:{
     topFilterInitFun() {
      return [
        { type: 'SELECT', label: '业务类型', fieldName: 'businessType', placeholder: '请选择', initialValue: '', itemList: this.createDictList('2585') },
     //   { type: 'SELECT', label: '是否查看', fieldName: 'viewStatus', placeholder: '请输入', initialValue: '',itemList: this.createDictList('1004') },
        { type: 'RANGE_DATE', label: '消息时间', fieldName: 'createdAt', valueFormat: 'yyyy-MM-dd', placeholder: '请选择' }
      
      ]
    },
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 100,
          fixed: 'left',
          render: props => {
            return (
              <div>
                <el-button size="mini" type="text" onClick={() => this.editHandle(props.row,'show')}>
                  查看
                </el-button>
              </div>
            );
          }
        },
        {
          title: '业务类型',
          dataIndex: 'businessType',
          sorter: true,
          filterItems: this.createDictList('2585'),
          render: props => {
            return <span>{this.createDictText(props.row.businessType, '2585')}</span>;
          }
        },
        {
          title: '待办事件数',
          dataIndex: 'count',
          sorter: true,
          filterItems: this.createDictList('1004')
        }, 
        // {
        //   title: '事件创建时间',
        //   dataIndex: 'taskMsg',
        //   sorter: true
        // },
        { title: '事件创建时间', dataIndex: 'createdAt', sorter: true ,dateFormat:'yyyy-MM-dd'}
        // { title: '提醒消息时间', dataIndex: 'publishDate',dateFormat:'yyyy-MM-dd HH:mm',sorter: true }
      ]
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = Object.assign({},val);
      this.fetchParams.startDate = formatdateByDay(this.fetchParams.createdAt[0]);
      this.fetchParams.endDate = formatdateByDay(this.fetchParams.createdAt[1]);
      console.log('搜索框数据：',this.fetchParams);
    },
    //展开收起时触发
    collapseHandle() {},
    editHandle(row,type){
      console.log("row:",row);
      this.initData =  {
        type: type,   // add-edit-show
        notificationId: row.notificationId,
        id:1001
      }; //行id
      //this.visibleDrawer = true;
  this.$router.push({
      path: '/'+row.menu_url,
      query: {
        type:'123'
      }
      
      })
    },
    //关闭详情 rData 是页面关闭回调回来的数据
    infoClose(rData) {
      this.visibleDrawer = false;
      if (rData.type === 'refresh') {
        // 重新加载
        this.fetchParams = { ...this.fetchParams };
      }
    },
   }
};
</script>

<style lang="less" scoped>
</style>
